#!/bin/bash
if [ -z "$GITHUB_PROXY" ]; then
    echo "Installing torch with cuda, try default index."
    source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/install_torch_win.sh"
else 
    echo "Installing torch with cuda, try nju index."
    source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/install_torch_win_nju.sh"
fi

exit_code=$?
if [ $exit_code -eq 1 ]; then
    echo "Installing torch with cuda, try aliyun index."
    source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/install_torch_win_aliyun.sh"
fi

exit_code=$?
if [ $exit_code -eq 1 ]; then
    echo "Installing torch with cuda, try nju index."
    source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/install_torch_win_nju.sh"
fi

exit_code=$?
if [ $exit_code -eq 1 ]; then
    echo "Installing torch with cuda, try http mirror addresses."
    if [ "$INSTALL_TORCH_VERSION" = "2.8.0" ]; then
        source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/install_torch_win_fixed_2.8.sh"
    else
        source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/install_torch_win_fixed_ver.sh"
    fi
fi